package com.ipan.weixin.msg.send;

import com.ipan.weixin.msg.general.XmlMsg;

/**
 * 发送语音消息
 * 
 * @author iPan
 * @version 2013-12-25
 */
public class VoiceSendMsg extends AbstractSendJsonMsg {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -6378422441524632741L;

	private Voice voice;
	
	public VoiceSendMsg() {
		super(XmlMsg.TYPE_VOICE);
	}
	
	public VoiceSendMsg(String touser, String mediaId) {
		super(touser, XmlMsg.TYPE_VOICE);
		setVoice(mediaId);
	}
	
	public Voice getVoice() {
		return voice;
	}

	public void setVoice(Voice voice) {
		this.voice = voice;
	}
	
	public void setVoice(String mediaId) {
		this.voice = new Voice(mediaId);
	}
	
	public String mediaId() {
		return (voice != null) ? voice.getMedia_id() : null;
	}

	class Voice {
		
		private String media_id;
		
		public Voice() {}

		public Voice(String media_id) {
			this.media_id = media_id;
		}

		public String getMedia_id() {
			return media_id;
		}

		public void setMedia_id(String media_id) {
			this.media_id = media_id;
		}
		
	}
	
//	public static void main(String[] args) {
//		VoiceServiceMsg msg = new VoiceServiceMsg("OPENID", "MEDIA_ID");
//		System.out.println(msg);
//	}

}

/*
发送：
{
"touser":"OPENID",
"msgtype":"voice",
"voice":
{
  "media_id":"MEDIA_ID"
}
}
*/